from rest_framework import serializers
from django.core.validators import MinLengthValidator

class NoteSummarySerializer(serializers.Serializer):
    """笔记总结序列化器"""
    content = serializers.CharField(
        required=True,
        validators=[MinLengthValidator(10)],
        error_messages={
            'required': '请提供笔记内容',
            'blank': '笔记内容不能为空',
            'min_length': '笔记内容至少需要10个字符'
        }
    )
    summary_type = serializers.ChoiceField(
        choices=['concise', 'detailed', 'structured'],
        default='concise',
        error_messages={
            'invalid_choice': '无效的总结类型'
        }
    )
    language = serializers.ChoiceField(
        choices=['zh', 'en'],
        default='zh',
        error_messages={
            'invalid_choice': '不支持的语言类型'
        }
    )

class AIAnalysisSerializer(serializers.Serializer):
    """AI分析序列化器"""
    content = serializers.CharField(
        required=True,
        validators=[MinLengthValidator(10)],
        error_messages={
            'required': '请提供待分析内容',
            'min_length': '内容至少需要10个字符'
        }
    )
    analysis_type = serializers.ChoiceField(
        choices=['note', 'general', 'task', 'study'],
        default='general',
        error_messages={
            'invalid_choice': '无效的分析类型'
        }
    )
    include_suggestions = serializers.BooleanField(default=True)
    max_points = serializers.IntegerField(min_value=1, max_value=10, default=5)

class AIPlanSerializer(serializers.Serializer):
    """AI计划生成序列化器"""
    content = serializers.CharField(
        required=True,
        validators=[MinLengthValidator(10)],
        error_messages={
            'required': '请提供计划内容',
            'min_length': '内容至少需要10个字符'
        }
    )
    plan_type = serializers.ChoiceField(
        choices=['exam', 'meeting', 'task', 'study'],
        default='exam',
        error_messages={
            'invalid_choice': '无效的计划类型'
        }
    )
    duration = serializers.ChoiceField(
        choices=['day', 'week', 'month'],
        default='week',
        error_messages={
            'invalid_choice': '无效的时间跨度'
        }
    )
    include_reminders = serializers.BooleanField(default=True)

class AIChatSerializer(serializers.Serializer):
    """AI聊天序列化器"""
    message = serializers.CharField(
        required=True,
        error_messages={
            'required': '请输入消息内容',
            'blank': '消息内容不能为空'
        }
    )
    context = serializers.DictField(required=False, default=dict)
    save_history = serializers.BooleanField(default=True)
    language = serializers.ChoiceField(
        choices=['zh', 'en'],
        default='zh'
    )